<template>
  <div class="statistic-card" :class="type">
    <div class="icon">
      <component :is="icon" />
    </div>
    <div class="content">
      <div class="title">{{ title }}</div>
      <div class="number">
        {{ number }}
        <span class="unit">{{ unit }}</span>
        <span class="trend" :class="trend">
          {{ rate }}
          <component :is="trend === 'up' ? ArrowUpOutlined : ArrowDownOutlined" />
        </span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons-vue'

defineProps<{
  icon: any
  title: string
  number: string
  unit: string
  rate: string
  trend: 'up' | 'down'
  type: 'primary' | 'success' | 'warning' | 'danger'
}>()
</script>

<style scoped lang="less">
.statistic-card {
  position: relative;
  display: flex;
  align-items: center;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow: hidden;
  transition: all 0.3s;
  min-width: 20vw;
  background: linear-gradient(135deg, var(--start-color) 0%, var(--end-color) 100%);
  
  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }

  &.primary {
    --start-color: #1890ff;
    --end-color: #40a9ff;
  }

  &.success {
    --start-color: #52c41a;
    --end-color: #73d13d;
  }

  &.warning {
    --start-color: #faad14;
    --end-color: #ffc53d;
  }

  &.danger {
    --start-color: #ff4d4f;
    --end-color: #ff7875;
  }

  .icon {
    font-size: 2rem;
    color: white;
    opacity: 0.8;
  }

  .content {
    margin-left: 1rem;

    .title {
      font-size: 0.875rem;
      color: white;
      opacity: 0.8;
    }

    .number {
      font-size: 1.5rem;
      font-weight: bold;
      color: white;
      margin-top: 0.25rem;
      display: flex;
      align-items: center;
      gap: 0.5rem;

      .unit {
        font-size: 0.875rem;
        font-weight: normal;
        opacity: 0.8;
      }

      .trend {
        font-size: 0.875rem;
        display: flex;
        align-items: center;
        gap: 0.25rem;
        background: rgba(255, 255, 255, 0.2);
        padding: 0.5rem;
        border-radius: 9999px;
        margin-left: 0.5rem;

        &.up, &.down {
          color: white;
        }
      }
    }
  }

  &::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 6rem;
    height: 100%;
    opacity: 0.1;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    animation: shine 2s infinite;
  }
}

@keyframes shine {
  0% {
    transform: translateX(-100%);
  }
  60% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(100%);
  }
}
</style> 